﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        Form1Presenter _presenter;

        public Form1(Form1Presenter presenter)
        {
            InitializeComponent();

            _presenter = presenter;

            listBox1.Format += listBox1_Format;

        }

        void listBox1_Format(object sender, ListControlConvertEventArgs e)
        {
            var contact = (Contact)e.ListItem;
            e.Value = contact.FirstName + " " + contact.LastName;
        }

       
        private void button1_Click(object sender, EventArgs e)
        {            
            listBox1.DataSource = _presenter.Contacts;
            listBox1.ValueMember = "Id";

        }

        private void button2_Click(object sender, EventArgs e)
        {
           
            listBox2.DataSource = _presenter.TaskItems;
            listBox2.ValueMember = "Id";
            listBox2.DisplayMember = "Name";
        }

        private void button3_Click(object sender, EventArgs e)
        {
            listBox3.DataSource = _presenter.Products;
            listBox3.ValueMember = "Id";
            listBox3.DisplayMember = "Name";
        }

        
    }
}
